<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import Add from "./../add/index";
import Launch from "@/components/launch/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {},
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "api/time-discount/pageTimeDiscount",
        delete: "api/time-discount/deleteTimeDiscount",
        detail: "api/time-discount/getTimeDiscount",
        stop: "api/time-discount/stopActivity",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {
        activityName: "",
        activityStatus: "",
      },

      mixinTable_tableSearchSenior: {
        startTimeStr: {
          type: String,
          value: null,
          default: null,
        },
        endTimeStr: {
          type: String,
          value: null,
          default: null,
        },
      },

      // 表格数据
      tableData: [],
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "活动名称",
            prop: "activityName",
            type: "",
          },
          {
            label: "活动状态",
            prop: "activityStatus",
            type: "",
          },
        ],
      },
    };
  },
  methods: {
    //  手动结束活动
    coolingDown(ids_) {
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      })
        .then(async () => {
          let that = this;

          let res = await that.$vFN.Http.post(
            {
              url: this.apiUrl.stop,
              data: {
                ids: ids_,
              },
            },
            window
          );
          if (res._ok) {
            that.mixinTable_refreshData();
            that.$vFN.Tools.messageSuccess("操作成功");
          }
        })
        .catch(() => {});
    },
    // 打开添加/修改
    editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
      });
    },
    //商品管理
    open(item) {
      console.log(11111);
      Add.init({
        appWindow: this.appWindow,
        id: item.id,
        activityStatus: item.activityStatus,
        item: item,
      });
    },

    async handle(obj_) {
      let activityStatus_ = "";
      if (obj_.activityStatus == 1) {
        activityStatus_ = 2;
      } else if (obj_.activityStatus == 2) {
        activityStatus_ = 3;
      }
      console.log("activityStatus_", activityStatus_);
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.update,
          data: {
            activityName: obj_.activityName,
            activityStatus: activityStatus_,
            startTimeStr: obj_.startTimeStr,
            id: obj_.id,
            endTimeStr: obj_.endTimeStr,
            activityTimeType: obj_.activityTimeType,
            promotionOverlayLst: obj_.promotionOverlay,
            deductOverlayLst: obj_.deductOverlay,
          },
        },
        window
      );
      if (res._ok) {
        this.mixinTable_refreshData();
        this.$vFN.Tools.messageSuccess("操作成功");
        this.editBoxClose();
      }
    },

    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>